<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>汇总查询</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../bangnuo/admin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../bangnuo/admin/style/admin.css" media="all">
    <link rel="stylesheet" href="../../../bangnuo/admin/layui/css/modules/laydate/default/laydate.css" media="all">
    <script src="../../../bangnuo/admin/layui/layui.all.js"></script>
    <script src="../../../bangnuo/admin/js/jquery-1.8.0.min.js"></script>
    <script src="../../../bangnuo/admin/layui/lay/modules/laypage.js"></script>
    <script src="../../../bangnuo/admin/layui/layui.js"></script>
</head>

<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">

                <!--<div class="layui-inline">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <select name="status">
                            <option value="">全部</option>
                            <option value="0">待支付</option>
                            <option value="1">支付成功</option>
                            <option value="2">支付失败</option>
                            <option value="3">已退款</option>
                        </select>
                    </div>
                </div>-->
               <!-- <div class="layui-inline">
                    <label class="layui-form-label">支付方式</label>
                    <div class="layui-input-block">
                        <select name="payWay">
                            <option value="">全部</option>
                            <option value="0">支付宝</option>
                            <option value="1">微信</option>
                        </select>
                    </div>
                </div>-->
                <!-- <div class="layui-inline">
                     <label class="layui-form-label">开始时间</label>
                     <div class="layui-input-block">
                         <input class=" form-control" name="startTime" id="startTime" placeholder="开始时间">
                     </div>
                 </div>
                 <div class="layui-inline">
                     <label class="layui-form-label">结束时间</label>
                     <div class="layui-input-block">
                         <input class=" form-control" name="endTime" id="endTime" placeholder="结束时间">
                     </div>
                 </div>-->


               <!-- <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin" id="demoReload" lay-submit
                            lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>-->
            </div>
        </div>

        <div class="layui-card-body">
            <table id="admin-demo" lay-filter="admin-demo"></table>
            <script type="text/html" id="imgTpl">
                <img style="display: inline-block; width: 50%; height: 100%;" src={ { d.avatar }}>
            </script>
        </div>
    </div>

</div>

</body>

<script src="../../../bangnuo/admin/layui/layui.js"></script>
<script type="text/html" id="tuiMoney">
    {{d.tuiMoney/100 }}
</script>
<script type="text/html" id="totalMoney">
    {{d.totalMoney/100 }}
</script>
<script type="text/html" id="settleAccounts">
    {{d.settleAccounts/100 }}
</script>
<script>

    layui.use(['table', 'form'], function () {
        var table = layui.table,
            form = layui.form;

        form.on('submit(LAY-user-front-search)', function (data) {
            var order = {
                // "outTradeNo": data.field.outTradeNo,
                // "serialNumber": data.field.serialNumber,
                "status": data.field.status,
                // "payType": data.field.payType,
                "payWay": data.field.payWay,
                "sn": data.field.sn,
                "startTime": data.field.startTime,
                "endTime": data.field.endTime,
                "agentIdAgentId": data.field.agentIdAgentId,
                "id": data.field.id
            }
            table.reload('admin-overloading', {
                url: '/order/queryCount',
                where: order,
                page: {
                    curr: 1
                }
            });
            return false;
        });
        //第一个实例
        table.render({
            elem: '#admin-demo',
            method: "POST",
            toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
            url: '/order/queryCount', //数据接口
            contentType: "application/json;charset=UTF-8",
            parseData: function (res) { //res 即为原始返回的数据
                console.log("res执行", res);
                return {
                    "code": 0, //解析接口状态
                    "msg": "", //解析提示文本
                    "count": res.queryResult.total, //解析数据长度
                    "data": res.queryResult.list//解析数据列表
                };
            },
            page: true, //开启分页
            limit: 5,
            id: "admin-overloading",
            limits: [5, 10, 20, 50, 100],
            cols: [
                [ //表头
                    {
                        field: 'total',
                        title: '订单数',
                        width: 150,
                        sort: true,
                        fixed: 'left'
                    },
                    /*{
                        field: 'consumeMoney',
                        title: '订单金额',
                        width: 150
                    },*/
                    {
                        field: 'tuiMoney',
                        title: '退款金额',
                        width: 150,
                        templet:"#tuiMoney"
                    },{
                        field: 'tuiNum',
                        title: '退款条数',
                        width: 150
                    },
                    {
                        field: 'totalMoney',
                        title: '实收金额',
                        width: 150,
                        templet:"#totalMoney"
                    },
                    {
                        field: 'settleAccounts',
                        title: '订单金额',
                        width: 150,
                        templet:"#settleAccounts"
                    },
                    {
                        field: 'createTime',
                        title: '日期',
                        width: 150,
                        templet: '<div>{{ layui.util.toDateString(d.createTime, "yyyy-MM-dd") }}</div>',
                    }
                ]
            ]
        });
        table.on('tool(admin-demo)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）
            if (layEvent === 'del') { //删除
                layer.confirm('真的删除行么', function (index) {
                    obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                    layer.close(index);
                    //向服务端发送删除指令
                    $.ajax({
                        type: "GET",
                        // url: "/adminEntity/delAdmin/" + data.adminUuid,
                        url: "/terminalEntity/delTerminal/" + data.terminalUuid,
                        async: true,
                        success: function (data) {
                            if (data.success == true) {
                                layer.msg("删除成功");
                            } else {
                                layer.msg("删除失败");
                            }
                        }
                    });
                });
            } else if (layEvent === 'edit') { //编辑
                //do something
                //同步更新缓存对应的值
                layer.open({
                    type: 2,
                    title: '修改器具',
                    area: ['500px', '600px'],
                    // content: 'users/edit-shop.html?id=' + data.adminUuid //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                    content: 'operation/edit-order.html?id=' + data.id//这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                });
                obj.update({
                    username: '123',
                    title: 'xxx'
                });
            } else if (layEvent === 'LAYTABLE_TIPS') {
                layer.alert('Hi，头部工具栏扩展的右侧图标。');
            }
        });
    });
</script>

</html>